package com.qtong.rotatenavigation.dao;

import com.qtong.rotatenavigation.entity.WebSite;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class WebSiteDBHelper extends SQLiteOpenHelper {
	private final String sqlCreateTable = "create table "
			+ WebSite.DataBaseProperties.TABLE_NAME + "("
			+ WebSite.DataBaseProperties._ID
			+ " integer primary key autoincrement not null,"
			+ WebSite.DataBaseProperties.NAME + " TEXT,"
			+ WebSite.DataBaseProperties.URL + " TEXT,"
			+ WebSite.DataBaseProperties.STATE + " TEXT);";

	public WebSiteDBHelper(Context context) {
		super(context, WebSite.DataBaseProperties.DB_NAME, null,
				WebSite.DataBaseProperties.DB_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(sqlCreateTable);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL("DROP TABLE IF EXISTS "
				+ WebSite.DataBaseProperties.TABLE_NAME);
		onCreate(db);

	}
}
